﻿using DeHeng_Mes.Dao;
using DeHeng_Mes.Model.ConfigModel;
using DeHeng_Mes.Model.Table;
using DeHeng_Mes.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeHeng_Mes.PlcService
{
    public class SpotCheakService
    {
        #region 成员实例
        OrderDao orderDao = new OrderDao();


        #endregion

        /// <summary>
        /// 执行点检
        /// </summary>
        /// <param name="station"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public byte StationSpotChackSave(string station, int index, Model.ConfigModel.PlcOrderConfigModel orderModel, string code)
        {
            List<int> errorCodes = new List<int>();

            try
            {
                orderDao.SpotChackSave(new SpotChack()
                {
                    PlcName = orderModel.PlcName,
                    CreateTime = DateTime.Now,
                    Station = station,
                    TraceId = code,
                    Status = "1",
                });

                Tools.ProduceLogText($"[{station}]执行点检任务成功,点检码[{code}]");

            }
            catch (Exception ex)
            {
                Tools.ProduceLogTextError($"[{station}]执行点检任务失败，原因是{ex.Message}");
            }
            return 2;
        }
    }
}
